/*
 * Copyright 2021 ThoughtWorks, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

@import "vals";
@import "../../global/hack-font";

$attention: #e6e699;
$info:      #9999e6;

.exec-editor {
  display: block;
  border-radius: 5px;
  padding: 15px;
  background-color: $task-editor-bg;
  color: $white;
  font-family: Hack, monospace;
  font-size: 14px;

  pre, code {
    font-family: inherit;
  }

  .comment {
    margin: 0;
    padding: 2px;
    color: lighten($text-color, 30%);

    strong {
      color: lighten($text-color, 40%);
    }
  }

  .help-content {
    max-width: 100%;
    margin-top: -0.5em;
    margin-bottom: 0.5em;

    .help-header {
      display: block;
      font-weight: bold;
      cursor: pointer;
      color: $info;

      &:before {
        content: "+ ";
      }
    }

    .help-body {
      margin: 0 0 0 1ex;
      padding: 0;
      display: none;
    }

    p {
      margin: 0;
      padding: 0;
    }

    &.open{
      .help-header {
        &:before {
          content: "- ";
        }
      }

      .help-body { display: block; }
    }
  }

  .caveats {
    .help-header {
      color: $attention;
    }

    &.open {
      float: none;
      clear: both;
    }
  }

  .current-editor::before,
  .cmd:first-child::before,
  .mod:first-child::before {
    @include no-select;

    content: "$";
    margin-left: calc(-2ex + 2px);
    margin-right: 4px;

    color: $task-prompt;
  }

  .current-editor {
    display: block;
    background-color: $task-bg;
    margin: 0;
    padding: 2px;
    padding-left: calc(2ex + 2px);

    &:focus {
      outline: none;
      background-color: $task-current-bg;

      &::before {
        color: $task-current-prompt;
      }
    }
  }

  .task {
    cursor: pointer;
    padding: 3px 2px;
    padding-left: calc(2ex + 2px);

    margin: 0; // don't add ANY margin or else user can click between the gaps and trigger parent handler => bad user experience, feels buggy

    .mod,
    .cmd,
    .args {
      padding: 0;
      margin: 0;
    }

    .mod {
      color: $task-mod-color;
      box-sizing: border-box;
      border-radius: 4px;
      padding: 0 5px;
      background-color: $task-mod-bg;

      &:before {
        float: left;
      }
    }

    .cmd {
      color: $task-cmd-color;
    }

    .args {
      color: $white;
    }

    .errors {
      white-space: normal;
      padding-top: 3px;
      color: lighten($go-danger, 20%);
      font-size: 11px;
      border-top: 2px dotted $go-danger;

      ul {
        list-style: none;
        margin-left: 0;
        padding-left: 1em;
        text-indent: -1em;

        li {
          padding: 0;
          margin: 0;

          &:before {
            content: "» ";
          }
        }
      }
    }

    &.has-errors {
      background-color: $task-err-bg;

      .cmd, .args, .mod {
        color: $white;
        background-color: transparent;
        padding: 0;

        &:before { color: $white; }
      }
    }
  }
}
